import { maintenanceHttp } from '/@/utils/http/axios';
import {
  AppBasicItem,
  AppMicroServiceItem,
  AppNamespaceItem,
  AppParams,
  AppSingleItem,
  BasicDataParams,
  TenantBasicDataItem,
  TenantItem,
  TenantLogDataItem,
  TenantSubscribedAppItem,
} from '/@/api/maintenance-center/resource-monitor/for-tenant/model/monitorModel';

enum Api {
  GET_TENANT_LIST = '/v1/maintenance/resourceStatistics/tenant/queryTenantList',
  GET_BASIC_DATA = '/v1/maintenance/resourceStatistics/tenant/baseData',
  GET_LOG_DATE = '/v1/maintenance/resourceStatistics/tenant/queryOpLogResource',
  GET_SUB_APP_LIST = '/v1/maintenance/resourceStatistics/tenant/queryTenantSubscribedAppList',
  GET_APP_BASIC_DATA = '/v1/maintenance/resourceStatistics/tenant/queryOrdinaryDetails',
  GET_SINGLE_APP_LIST = '/v1/maintenance/resourceStatistics/tenant/queryComponentListOfMonomer',
  GET_MICROSERVICE_APP_LIST = '/v1/maintenance/resourceStatistics/tenant/queryComponentListOfMicroservice',
  GET_NAMESPACE_AND_CLUSTER = '/v1/maintenance/resourceStatistics/tenant/queryNamespaceAndCluster',
}

export const getTenantList = () => {
  // 获取租户列表
  return maintenanceHttp.get<TenantItem[]>({ url: Api.GET_TENANT_LIST });
};

export const getTenantBasicInfo = (params: BasicDataParams) => {
  // 获取租户基本信息
  return maintenanceHttp.get<TenantBasicDataItem>({
    url: Api.GET_BASIC_DATA,
    params,
  });
};

export const getTenantLog = (params: BasicDataParams) => {
  // 获取租户日志信息
  return maintenanceHttp.get<TenantLogDataItem>({
    url: Api.GET_LOG_DATE,
    params,
  });
};

export const getTenantSubscribedAppList = (params: BasicDataParams) => {
  // 获取租户订阅应用信息
  return maintenanceHttp.get<TenantSubscribedAppItem[]>({
    url: Api.GET_SUB_APP_LIST,
    params,
  });
};

export const getAppBasicInfo = (params: AppParams) => {
  // 获取应用基本信息
  return maintenanceHttp.get<AppBasicItem>({
    url: Api.GET_APP_BASIC_DATA,
    params,
  });
};

export const getSingleList = (params: AppParams) => {
  // 获取单体应用信息
  return maintenanceHttp.get<AppSingleItem[]>({
    url: Api.GET_SINGLE_APP_LIST,
    params,
  });
};

export const getMicroServiceList = (params: AppParams) => {
  // 获取微服务应用信息,
  return maintenanceHttp.get<AppMicroServiceItem[]>({
    url: Api.GET_MICROSERVICE_APP_LIST,
    params,
  });
};

export const getNamespaceAndCluster = (params: AppParams) => {
  // 获取微服务命名空间信息
  return maintenanceHttp.get<AppNamespaceItem>({
    url: Api.GET_NAMESPACE_AND_CLUSTER,
    params,
  });
};
